<?php
/*
 * 新锐微信登录 [ 深圳市新锐创意科技有限公司旗下产品 ]
 * Copyright  2015-2099 www.xinruiweb.com  All Rights Reserved.
 * 技术开发: 75674952@qq.com
 * 请支持正版授权产品
 */

if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
	exit('Access Denied');
}


require_once DISCUZ_ROOT.'./source/plugin/xinrui_mobilereg/config.php';


$username = trim($_REQUEST['username']);

$uid = trim($_REQUEST['uid']);

$import = trim($_REQUEST['import']);

showformheader('plugins&operation=config&do='.$pluginid.'&identifier='.$plugin['identifier'].'&pmod=admincp_list', 'enctype');

showtableheader($_G['XRLANG_MOBLIEREG']['admin_list_search']);
showsetting($_G['XRLANG_MOBLIEREG']['admin_list_user'], 'username', $username, 'text', '', 0);
showsetting($_G['XRLANG_MOBLIEREG']['admin_list_uid'], 'uid', $uid, 'text', '', 0);
showsetting($_G['XRLANG_MOBLIEREG']['import'], 'import', 0, 'radio', 0, 0, '');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
$where = ' 1 = 1 ';
if($username){
    $where .= " and username = '".$username."'";
}
if($uid){
    $where .= " and uid = '".$uid."'";
}

if($import == 1){   //导出

    $list = DB::fetch_all("select * from ".DB::table('xinrui_mobilereg_user')." where  $where order by id desc ");
    $str = $_G['XRLANG_MOBLIEREG']['admin_list_table0'].",".$_G['XRLANG_MOBLIEREG']['admin_list_uid'].",".$_G['XRLANG_MOBLIEREG']['admin_list_table2'].",".$_G['XRLANG_MOBLIEREG']['admin_list_table1'].",".$_G['XRLANG_MOBLIEREG']['admin_list_table7'].",".$_G['XRLANG_MOBLIEREG']['admin_list_table3'].",".$_G['XRLANG_MOBLIEREG']['admin_list_table8']."\n";
    $str = iconv('utf-8','gb2312',$str);
    foreach($list as $data) {
        $data['isuser'] = ($data['isuser'] == 1)?$_G['XRLANG_MOBLIEREG']['admin_list_yes']:$_G['XRLANG_MOBLIEREG']['admin_list_no'];
        $data['bind'] = ($data['uid'] == $data['bind'])?$_G['XRLANG_MOBLIEREG']['admin_list_no']:'<a href="home.php?mod=space&uid='.$data['uid'].'" target="_blank">'.$data['uid'].'</a>';
        $data['ispwd'] = ($data['ispwd'] == 1)?$_G['XRLANG_MOBLIEREG']['admin_list_yes']:$_G['XRLANG_MOBLIEREG']['admin_list_no'];

        $id = iconv('utf-8','gb2312',$data['id']);
        $uid = iconv('utf-8','gb2312',$data['uid']);
        $username = iconv('utf-8','gb2312',$data['username']);
        $user = iconv('utf-8','gb2312',$data['user']);
        $isuser = iconv('utf-8','gb2312',$data['isuser']);
        $bind = iconv('utf-8','gb2312',$data['bind']);
        $ispwd = iconv('utf-8','gb2312',$data['ispwd']);
        $str .= $id.",".$uid.",".$username.",".$user.",".$isuser.",".$bind.",".$ispwd."\n";
    }
    ob_end_clean();
    $filename = date('Ymd').'.csv';
    header("Content-type:text/csv");
    header("Content-Disposition:attachment;filename=".$filename);
    header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
    header('Expires:0');
    header('Pragma:public');
    echo $str;
    exit;
}

showtableheader($_G['XRLANG_MOBLIEREG']['admin_list_title']);
showsubtitle(array(
    $_G['XRLANG_MOBLIEREG']['admin_list_table0'],
    $_G['XRLANG_MOBLIEREG']['admin_list_uid'],
    $_G['XRLANG_MOBLIEREG']['admin_list_table2'],
	$_G['XRLANG_MOBLIEREG']['admin_list_table1'],
    $_G['XRLANG_MOBLIEREG']['admin_list_table7'],
    $_G['XRLANG_MOBLIEREG']['admin_list_table3'],
    $_G['XRLANG_MOBLIEREG']['admin_list_table8'],
));

$pagenum=20;
$page=max(1,intval($_GET['page']));
$count=DB::result_first("select count(*) from ".DB::table('xinrui_mobilereg_user')." where $where");
$list=DB::fetch_all("select * from ".DB::table('xinrui_mobilereg_user')." where  $where order by id desc ".DB::limit(($page-1)*$pagenum,$pagenum));
foreach($list as $data) {
	showtablerow('', array('class="td_k"', 'class="td_k"', 'class="td_l"'), array(
		$data['id'],
        $data['uid'],
        $data['username'],
        $data['user'],
        $data['isuser'] == 1?$_G['XRLANG_MOBLIEREG']['admin_list_yes']:$_G['XRLANG_MOBLIEREG']['admin_list_no'],
		$data['bind'] = ($data['uid'] == $data['bind'])?$_G['XRLANG_MOBLIEREG']['admin_list_no']:'<a href="home.php?mod=space&uid='.$data['uid'].'" target="_blank">'.$data['uid'].'</a>',
        $data['ispwd'] == 1?$_G['XRLANG_MOBLIEREG']['admin_list_yes']:$_G['XRLANG_MOBLIEREG']['admin_list_no'],
	));
}
showtablefooter();
echo multi($count,$pagenum,$page,ADMINSCRIPT."?action=plugins&operation=config&do=$pluginid&identifier=".$plugin['identifier']."&pmod=admincp_list&username=".$username."&uid=".$uid."");
?>